<?php

define('SYMFONY_DEV', false);
define('CACHE_TIMEOUT', 1800);
define('CACHE_ENABLED', false);

require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', (SYMFONY_DEV ? 'dev' : 'prod'), (SYMFONY_DEV ? true : false));

$instance = sfContext::createInstance($configuration);

if(CACHE_ENABLED)
	$cache_this_page = $_SERVER['REQUEST_METHOD'] == 'GET' && $_SESSION['symfony/user/sfUser/authenticated'] == 0;
else 
	$cache_this_page = false;

if($cache_this_page){
	$SESS = $_SESSION;
	unset($SESS['symfony/user/sfUser/lastRequest']);
	$unique = md5($_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'].base64_encode(serialize($SESS)));
	$cached_html_path = 'webcache/'.$unique;
	if(file_exists($cached_html_path)){
		if(time()-filemtime($cached_html_path) < CACHE_TIMEOUT){
			readfile($cached_html_path);
			goto end;
		} else {
			unlink($cached_html_path);
		}
	}
	ob_start();
}

$instance->dispatch();

if($cache_this_page){
	$html = ob_get_clean();
	if(!file_exists('/webcache/')) mkdir('webcache');
	$html = preg_replace('/\s+/'," ", $html);
	$html = str_replace('> <',"><", $html);
	file_put_contents($cached_html_path, $html);
	echo $html;
}
end:
?><!--
developed by
                                                             
                   _/            _/  _/                      
    _/_/_/    _/_/_/    _/_/    _/        _/_/_/    _/_/_/   
 _/    _/  _/    _/  _/_/_/_/  _/  _/  _/    _/  _/_/        
_/    _/  _/    _/  _/        _/  _/  _/    _/      _/_/     
 _/_/_/    _/_/_/    _/_/_/  _/  _/    _/_/_/  _/_/_/
                                _/                           
                             _/
-->